#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "global_define.h"


int main(int argc , char * argv[]) {
	int fd = -1;
	int ret = -1;

	MSG msg;
	memset(&msg, 0 , sizeof(MSG));
	msg.state = 1;// 默认找 S(可中断的睡眠状态) 状态的进程

	if (argc >= 2){
		msg.state = atoi(argv[1]);
	}

	fd = open("/dev/pid_state_cnt", O_RDWR);
	if(fd < 0) {
		fprintf(stderr, "open /dev/pid_state_cnt error\n");
		return -1;
	}

	ret = ioctl(fd,PID_STATE_CNT_GET, &msg );
	if(ret) {
		fprintf(stderr, "open /dev/pid_state_cnt error\n");
		return -1;
	}
	printf("the state:%d cnt:%d\n", msg.state, msg.cnt);
	return 0;
}
